<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // data  需要数据
    //success 函数类型的参数
    function ajax(data, success) {
      if (data == "衣服") {
        success(["大衣", "短衣", "短裤"])
      } else if (data == "鞋子") {
        success(["男鞋", "女鞋", "童鞋"])
      }

    }
    ajax("衣服", function (res) {
      console.log(res)
    })
    // 回调函数  调用函数时 传入的函数类型的实参     并被执行传递实参
    ajax("鞋子", function (res) {
      console.log(res)
    })

  </script>
</body>

</html>